package jtk.project4.fleet.field;

import java.text.SimpleDateFormat;

import jtk.project4.fleet.domain.TireInv;

import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.TextField;

public class PurchaseInfoAddEditTireToInventoryField extends GroupControl<TireInv>{
	private ComboField<String> VendorField;
	private TextField InvoiceField;
	private TextField PriceField;
	private CalendarControl purchaseDateField;
	
	public PurchaseInfoAddEditTireToInventoryField(String bindID){
		setTitle("header.PurchaseInformation");
		setBindID(bindID);
		createFields();
		createLayout();
	}
	
	private void createFields(){
		//Kalender (MASIH SALAH)
		purchaseDateField = new CalendarControl ("PurchDate", 20);
		purchaseDateField.setFormat(new SimpleDateFormat(translate("MM/dd/yyyy")));
		purchaseDateField.showYearSpinner(true);
		
		purchaseDateField.setEditable(false);
		//SpinnerField
		
		InvoiceField = new TextField ("invNo", 30);
		//InvoiceField.setRequired(true);
		purchaseDateField.setPreferredSize(InvoiceField.getPreferredSize());
		
		PriceField = new TextField ("price", 20);
		//PriceField.setRequired(true);
		
		
		//combobox yg awal kosong
		VendorField = new ComboField<String>("vendorId", " ");//kiri: nama table, kanan: data
		//purchaseDateField = new ComboField<String>("Inventory", " ");
	}
	
	private void createLayout(){
		setLayout(new FormLayout())
		.addLabel("label.Vendor").addField(VendorField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.Invoice #").addField(InvoiceField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.Price").addField(PriceField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.PurchaseDate").addField(purchaseDateField);
	}
}
